{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import  cv2 as cv\n",
    "filename = r'./lena.jpg'\n",
    "img = cv.imread(filename)\n",
    "#把原始图像转换成灰度图像\n",
    "gray = cv.cvtColor(img, cv.COLOR_RGB2GRAY)\n",
    "\n",
    "cv.imshow(\"cource image\", img) #原始图\n",
    "cv.imshow(\"gray\", gray) #灰度图\n",
    "cv.waitKey()\n",
    "\n",
    "#把原始图像转换为HSV图像 三个通道分离显示\n",
    "hsv = cv.cvtColor(img, cv.COLOR_RGB2HSV)\n",
    "cv.imshow(\"Hue\", hsv[:, :, 0]) #色度通道\n",
    "cv.imshow(\"Saturation\", hsv[:, :, 1]) #饱和度通道\n",
    "cv.imshow(\"Value\", hsv[:, :, 2]) #亮度通道\n",
    "cv.waitKey()\n",
    "#BGR 通道分离结果\n",
    "cv.imshow(\"Blue\", img[:, :, 0])\n",
    "cv.imshow(\"Green\", img[:, :, 1])\n",
    "cv.imshow(\"Red\", img[:, :, 2])\n",
    "cv.waitKey()\n",
    "cv.destroyAllWindows()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
